package com.mission.schedule.adapter;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mission.schedule.R;
import com.mission.schedule.adapter.utils.CommonAdapter;
import com.mission.schedule.adapter.utils.ViewHolder;
import com.mission.schedule.bean.TagCommandBean;
import com.mission.schedule.bean.qd606.CLInventoryListBean;
import com.mission.schedule.bean.qd606.NoteTitleDetailBean;

import java.util.List;
import java.util.Map;

public class QDPXAdapter extends CommonAdapter<NoteTitleDetailBean.ListBean> {

    public List<NoteTitleDetailBean.ListBean> mlList;
    private Handler handler;
    int stylee = 0;

    public QDPXAdapter(Context context, List<NoteTitleDetailBean.ListBean> lDatas, Handler handler,
                       int layoutItemID, int stylee) {
        super(context, lDatas, layoutItemID);
        this.mlList = lDatas;
        this.handler = handler;
        this.stylee = stylee;
    }


    @Override
    public void getViewItem(ViewHolder holder, NoteTitleDetailBean.ListBean item, int position) {
        TextView content_tv = (TextView) holder.getView(R.id.content_tv);
        RelativeLayout tuodong_rl = (RelativeLayout) holder.getView(R.id.tuodong_rl);
        RelativeLayout ll = (RelativeLayout) holder.getView(R.id.ll);
        TextView xh = (TextView) holder.getView(R.id.xh);
        ImageView dd = (ImageView) holder.getView(R.id.dd);
        ImageView ch = (ImageView) holder.getView(R.id.ch);
        ImageView santai = (ImageView) holder.getView(R.id.santai);
        content_tv.setText(item.contents);
        if (stylee == 0) {
            ll.setVisibility(View.VISIBLE);
            ch.setVisibility(View.VISIBLE);
            if (mlList.get(position).endstate == 0) {
                ch.setBackground(context.getResources().getDrawable(R.mipmap.btn_qd_unfinish_c));
            } else {
                ch.setBackground(context.getResources().getDrawable(R.mipmap.btn_qd_finish_c));
            }
            dd.setVisibility(View.GONE);
            xh.setVisibility(View.GONE);
            santai.setVisibility(View.GONE);
        } else if (stylee == 1) {
            ll.setVisibility(View.VISIBLE);
            ch.setVisibility(View.GONE);
            dd.setVisibility(View.VISIBLE);
            xh.setVisibility(View.GONE);
            santai.setVisibility(View.GONE);
        } else if (stylee == 2) {
            ll.setVisibility(View.VISIBLE);
            ch.setVisibility(View.GONE);
            dd.setVisibility(View.GONE);
            xh.setVisibility(View.VISIBLE);
            santai.setVisibility(View.GONE);
        } else if (stylee == 3) {
            ch.setVisibility(View.GONE);
            dd.setVisibility(View.GONE);
            xh.setVisibility(View.GONE);
            ll.setVisibility(View.GONE);
            santai.setVisibility(View.GONE);
        } else if (stylee == 4) {
            ch.setVisibility(View.GONE);
            dd.setVisibility(View.GONE);
            xh.setVisibility(View.GONE);
            ll.setVisibility(View.VISIBLE);
            santai.setVisibility(View.VISIBLE);
            if (mlList.get(position).endstate == 0) {
                santai.setBackground(context.getResources().getDrawable(R.mipmap.icon_santai1));
            } else if (mlList.get(position).endstate == 1) {
                santai.setBackground(context.getResources().getDrawable(R.mipmap.icon_santai2));
            } else {
                santai.setBackground(context.getResources().getDrawable(R.mipmap.icon_santai3));
            }
        }
    }

    public void remove(NoteTitleDetailBean.ListBean item) {
        if (item != null && mlList != null) {
            mlList.remove(item);
        }
    }

    public void insert(NoteTitleDetailBean.ListBean item, int to) {
        if (item != null) {
            mlList.add(to, item);
        }
    }
}
